from sqlalchemy import Column, Integer, Date, DateTime, String
from sqlalchemy.dialects.mysql import DECIMAL
from datetime import datetime

from config.database import Base


class KylinFutureDailyQuote(Base):
    """
    期货日线行情表
    """

    __tablename__ = 'kylin_future_daily_quote'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='行情id')
    code = Column(String(20), nullable=False, comment='期货代码')
    date = Column(Date, nullable=False, comment='交易日期')
    open = Column(DECIMAL(10, 4), nullable=False, comment='开盘价')
    high = Column(DECIMAL(10, 4), nullable=False, comment='最高价')
    low = Column(DECIMAL(10, 4), nullable=False, comment='最低价')
    close = Column(DECIMAL(10, 4), nullable=False, comment='收盘价')
    volume = Column(Integer, nullable=True, default=0, comment='成交量')
    hold = Column(Integer, nullable=True, default=0, comment='持仓量')
    settle = Column(DECIMAL(10, 4), nullable=True, comment='结算价')
    create_time = Column(DateTime, default=datetime.now, comment='创建时间')
    update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')